package com.kdgz.kdgz.thread;

import com.kdgz.kdgz.beans.Orders;
import com.kdgz.kdgz.beans.Staff;
import com.kdgz.kdgz.beans.StaffOrders;
import com.kdgz.kdgz.mapper.StaffOrderMapper;
import com.kdgz.kdgz.sevice.AreaService;
import com.kdgz.kdgz.sevice.StaffService;
import com.kdgz.kdgz.util.RandomOrders;
import com.kdgz.kdgz.util.SendOrders;
import org.ietf.jgss.Oid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Random;

/**
 * @Author Veneno
 * @Desc 模拟快递生成
 * @date 2021/3/23
 */
@Component
@Order(value = 13)
public class OrderThread implements ApplicationRunner {
    @Autowired
    RandomOrders randomOrders;
    @Autowired
    StaffService staffService;
    @Autowired
    StaffOrderMapper staffOrderMapper;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                while (true){
                    // 随机生成快递数量
                    int random = new Random().nextInt(1000) + 4000;
                    for (int i = 0; i < random; i++) {
                        Orders order = randomOrders.randInfo();
                    }
                    try {
                        //生成货物时间间隔
                        Thread.sleep(1000*60*60*24);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        new Thread(runnable).start();
    }
}
